#include <stdio.h>
int main(){
    int T,n;
    scanf("%d",&T);
    int sky,ground;
    for(int i=1;i<=T;i++){
        scanf("%d",&n);
        sky=n%10;
        sky=(sky-4+10)%10;
        ground=n%12;
        ground=(ground-4+12)%12;
        printf("%d%c\n",sky,'A'+ground);
    }
    return 0;
}